package hibernate;


import javax.imageio.spi.ServiceRegistry;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;

import forms.registroUsuarios;



public class HibernateUtil {
	
	private static  final SessionFactory sessionFactory;
	
	//private static SessionFactory buildSessionFactory() {
	static{
    	
        try {
        	 sessionFactory= new AnnotationConfiguration()
        	 .addAnnotatedClass(registroUsuarios.class)
        	 .configure().buildSessionFactory();                   
        	
        }
        
        catch (Throwable ex) {
            // Make sure you log the exception, as it might be swallowed
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }

    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }

}
